home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
ip
/
ka9q
/
xobbs.arc
/
xoio.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-05-03
|
2KB
|
85 lines
/*XOIO.C Input/Output routines for XOBBS. Jim Durham, W2XO 2-13-89 */
/*Version 1.1*/
/*Code released to the amateur radio community*/
#include "xobbs.h"
getline(mode)
int mode;
{
static int msgbytes,savcnt,i;
static char *mp,*cp;
static char savbuf[1024]; /* buffer for saved chars */
if(local){ /* if local, get input from stdin*/
fgetline(infd,inline);
alarm(180);
}
else{
if(savcnt){
strncpy(msg.mtext,savbuf,savcnt);
msgbytes = savcnt;
}
else{
msgbytes = msgrcv(rmsgqid,&msg,1024,(long)pid,0600);/*get a message*/
}
cp = inline;
mp = msg.mtext; /*point to message text*/
while(((*cp = *mp) != 0x0d) && ((*cp != 0x0a)
&& ((int)(cp-inline) < 254))){
cp++;
mp++;
msgbytes--;
if(msgbytes < 1){
msgbytes = msgrcv(rmsgqid,&msg,1024,(long)pid,0600);
mp = msg.mtext;
}
}
if((*cp != 0x0d) && (*cp != 0x0a))
cp++;
*cp = '\0';
msgbytes--; /*count the CR*/
mp++; /* and skip it*/
savcnt = msgbytes;
strncpy(savbuf,mp,msgbytes);
}
if(mode == 1) return;
i = strlen(inline);
while(i--) if(islower(inline[i])) inline[i]=toupper(inline[i]);
}
cgetline()
{
int gotbytes;
if(local)
printf("cgetline called from local!\n");
else{ /*get a message from the receive que*/
if((gotbytes = msgrcv(rcmsgqid,&msg,1024,(long)pid,0600)) < 0){
perror("cgetline");
gotbytes = 0;
}
msg.mtext[gotbytes] = '\0';
strcpy(inline,msg.mtext);
} /*if local/else */
}
printerr()
{
sprintf(prinbuf,"\n*** Bad Command\n");
prinout(NOFLUSH);
}
printnone()
{
sprintf(prinbuf,"\n*** None Found\n");
prinout(NOFLUSH);
}